package com.jetgege.smartbox.BoxSetting;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.jetgege.smartbox.Base.App;
import com.jetgege.smartbox.Base.BaseActivity;
import com.jetgege.smartbox.Model.UserModel;
import com.jetgege.smartbox.R;

import butterknife.BindView;

public class EditBoxActivity extends BaseActivity {

    @BindView(R.id.edit_box_toolbar)
    Toolbar editBoxToolbar;

    UserModel userModel;
    @Override
    protected int getLayoutId() {
        return R.layout.activity_edit_box;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initValue();
        eventHandle();
    }

    private void initValue() {
        editBoxToolbar.setTitle("盒子");
        setSupportActionBar(editBoxToolbar);
        // Navigation Icon 要設定在 setSupoortActionBar 才有作用
        // 否則會出現 back button
        editBoxToolbar.setNavigationIcon(R.drawable.bar_back_btn);
//获取用户
        int position = getIntent().getIntExtra("Position", 0);
        userModel = App.mDevices.getUserModels().get(position);

    }

    private void eventHandle() {
        editBoxToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
                overridePendingTransition(R.anim.in_from_left, R.anim.out_to_right);
            }
        });

    }

    //  添加编辑
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.device_pwd, menu);
        return true;
    }

    /**
     * 修改完成
     * @param item
     * @return
     */
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        finish();
        return true;
    }





}
